﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace ZQNB.Web
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("{*allfavicon}", new { allfavicon = @".*\.ico(/?.*)?" });
            routes.IgnoreRoute("{*allaxd}", new { allaxd = @".*\.axd(/?.*)?" });
            routes.IgnoreRoute("{*alljpg}", new { alljpg = @".*\.jpe?g(/?.*)?" });
            routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*\.aspx(/?.*)?" });
            
            CmsRouteConfig.RegisterRoutes(routes);

            routes.MapRoute(
                "",
                "",
                new { controller = "Home", action = "Index"},
                new[] { "ZQNB.Web.Controllers" }
            );


            routes.MapRoute(
                "Common_Default",
                "Common/{controller}/{action}",
                namespaces: new[] { "ZQNB.Web.Controllers", "ZQNB.Web.Common.Controllers" }
            );

            ////保留字（站群通用接口）:
            //routes.MapRoute(
            //    "Portal_Default",
            //    "Portal/{controller}/{action}/{id}",
            //    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            //    namespaces: new[] { "ZQNB.Web.Controllers"}
            //);

            //routes.MapRoute(
            //    "Common_Default",
            //    "Common/{controller}/{action}/{id}",
            //    defaults: new { id = UrlParameter.Optional },
            //    namespaces: new[] { "ZQNB.Web.Common.Controllers" }
            //);

            //routes.MapRoute(
            //    "SiteUrl",
            //    "{site}/{area}/{controller}/{action}",
            //    namespaces: new[] { "ZQNB.Web.Areas.*.Controllers" }
            //);

            //routes.MapRoute(
            //    "SpaceUrl",
            //    "space/{owner}/{controller}/{action}"
            //);

            //routes.MapRoute(
            //    "Url",
            //    "{area}/{controller}/{action}"
            //);

            ////ajax call
            ////_MvcCaptcha/MvcCaptchaLoader?null
            //routes.MapRoute(
            //    "Captcha_Default",
            //    "_MvcCaptcha/MvcCaptchaLoader",
            //    defaults: new { controller = "_MvcCaptcha", action = "MvcCaptchaLoader" },
            //    namespaces: new[] { "ZQNB.Common.Web" }
            //);


        }
    }


    public class CmsRouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.MapRoute(
                "Cms",
                "Cms/{site}/{pageUri}",
                defaults: new { controller = "Cms", action = "Page", pageUri="Index" },
                namespaces: new[] { "ZQNB.Web.Controllers", "ZQNB.Web.Common.Controllers" }
            );

            //routes.MapRoute(
            //"Cms",
            //"Cms/{site}/{pageUri}",
            //defaults: new { controller = "Cms", action = "Page", pageUri = "Index" },
            //namespaces: new[] { "ZQNB.Web.Controllers", "ZQNB.Web.Common.Controllers" }
            //);


            //routes.MapPageRoute("", "abc", "~/abc.cshtml");
            //routes.MapPageRoute("", "site1/abc", "~/abc.cshtml");

        }
    }
}
